import 'package:flutter_elf/config/component_index.dart';

class RawGestureDetectorPage extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return RawGestureDetectorPageState();
  }
}

class RawGestureDetectorPageState extends State<RawGestureDetectorPage>{

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_){
      NavigatorUtils.navigatorReplaceRouter(context, TouchDemo());
    });

  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      body: PageView()
    );
  }
}

class TouchDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Listener(
      child: Container(
          color: Colors.blue,
          width: 300,
          height: 300,
          child: Stack(
            //将布局按比例分成坐标，原点(0,0)位于中间，(-1,-1)为左上
            alignment: Alignment(0, 0),
            children: <Widget>[
              Listener(
                child: Container(
                  color: Colors.red,
                  width: 100,
                  height: 100,
                ),
                onPointerDown: (event){
                  globalPrint("内层");
                },
              ),
            ],
          )
      ),
      onPointerDown: (event){
        globalPrint("外层");
      },
      behavior: HitTestBehavior.translucent,
    );
  }
}